package com.hmdp.entity;


public enum MessageStatus {
    PENDING(0, "待发送"),
    SUCCESS(1, "已发送"),
    TRYING(2, "尝试中"),
    FAILED(3, "发送失败");
    
    private int code;
    private String desc;
    
    MessageStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 获取状态码
     */
    public int getCode() {
        return code;
    }

    /**
     * 获取状态描述
     */
    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取枚举
     */
    public static MessageStatus getByCode(int code) {
        for (MessageStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

}